﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using KTX.Public;
using KTX.BLL;

namespace KTX.Giaodien
{
    public partial class frmCanBoDemo : Form
    {
        public frmCanBoDemo()
        {
            InitializeComponent();
        }
        CanBoBLL cls = new CanBoBLL();
        private void frmCanBo_Load(object sender, EventArgs e)
        {            
            dataGridView2.DataSource= cls.LoadCanBo();
        }
      
        private void btnTimkiem_Click(object sender, EventArgs e)
        {
            
            CanBoPublic p = new CanBoPublic();
            //p.CanBoMa = txtCanBoMa.Text.Trim();
            //p.CanBoMa = txtCanBoMa.Text.Trim();
            dataGridView2.DataSource = cls.TimtheoMaCanBo(p);            
        }

        private void btnXoa_Click(object sender, EventArgs e)
        {
            CanBoPublic p = new CanBoPublic();
            //p.CanBoMa = txtCanBoMa.Text.Trim();
            int kq = cls.Xoa(p);
            if (kq > 0)
            {
                MessageBox.Show("Bạn đã xóa Thành công");
                frmCanBo_Load(sender, e);
            }
        }

        private void btnThem_Click(object sender, EventArgs e)
        {
            CanBoPublic p = new CanBoPublic();
            p.CanBoMa = txtMaCB.Text.Trim();
            p.CanBoTen = txtTenCB.Text.Trim();
            p.CanBoChucVu = txtChucvu.Text.Trim();                
            int kq = cls.Them(p);
            if (kq > 0)
                MessageBox.Show("Thêm thành công");
            else
                MessageBox.Show("Chưa có dòng nào được thêm");
            frmCanBo_Load(sender, e);
        }

       
    }
}
